layui.use(['form'],function(){		
			
		var form=layui.form;
		form.render();
		
		function login(account,passWord){
			$.ajax({
				type:"get",
				url:"base/data/login/login.json",//请求的接口路径
				async:true,
				data:{
					"account":account,
					"passWord":passWord
				},//设置参数
				//ajax执行之前
				"beforeSend":function(){
					layer.load(1,{
						shade:[0.5,'grey']
					});
				},
				//ajax执行成功后的回调函数
				"success":function(result){
					//result为Ajax所响应的数据
					console.log(result);
					if(result.code==0){
						localStorage.setItem("userId",result.data.user_id);
						localStorage.setItem("userName",result.data.name);
						localStorage.setItem("headImg",result.data.head_img_url);
						location.href="views/index.html";
					}else{
						layer.msg("登录失败",{
							icon:2,
							time:1000,
							top:300,
							left:500 
						});
					}
				},
				"error":function(){
					layer.msg("未知错误,请刷新页面",{
							icon:2,
							time:1000,
							top:300,
							left:500
						
					});
				}
			});
		}
		
		form.on('submit(login)', function() {
						var account = $("#account").val();
						var passWord = $("#passWord").val();
					if($("#remember").is(":checked")) {
						localStorage.setItem("account", account);
						localStorage.setItem("passWord", passWord);
				} else {
						localStorage.setItem("account", "");
						localStorage.setItem("passWord", "");
						//localStorage.clear();
					}
					login(account,passWord);
					return false; //组织表单跳转，如果需要表单跳转，去掉这段
				});

				function remembers() {
					if(localStorage.getItem("account") != "" && localStorage.getItem("passWord") != "") {
						$("#account").val(localStorage.getItem("account"));
						$("#passWord").val(localStorage.getItem("passWord"));
						$("#remember").prop("checked", true);
					}
					form.render();
				}
				remembers();
				function addUnclock(){
			var engLish=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];
			var attr=[];
			var code="";
			for(var i=0;i<4;i++){
				 var ranNum = Math.ceil(Math.random() * 25);
				 if(attr.indexOf(ranNum)==-1){
				 	attr.push(ranNum);
				 }else{
				 	i--;
				 }
				 console.log(attr);
			}
			console.log(attr);
			
			for(var i=0;i<4;i++){
				code+=engLish[attr[i]];
				console.log(engLish[attr[i]]);
				
			}
			$(".captcha_gbws_wrap").remove();
			$(".login").buttonCaptcha({
				codeWord:code,//匹配的验证码
				codeZone:code,
				captchaHeader:"请正确的将字符移动到框内",
				captchaUnlocked:"通过验证"
			});
			$(".captcha_gbws_wrap").appendTo("#verifygroup");
		}
		addUnclock();
		 
		});	